package com.gitee.feizns.menu.exception;

/**
 * 尝试对不可枚举的类型, 进行枚举操作
 * @author feizns
 * @since 2019/5/4 0004
 */
public class NotEnumeratedException extends RuntimeException {

    /**
     * 不可枚举的类型
     */
    private Class<?> notEnumerated;

    public NotEnumeratedException(Class<?> notEnumerated) {
        this.notEnumerated = notEnumerated;
    }

    public NotEnumeratedException(String message, Class<?> notEnumerated) {
        super(message);
        this.notEnumerated = notEnumerated;
    }

    public Class<?> getNotEnumerated() {
        return notEnumerated;
    }

    /**
     * @param clz
     */
    public static void checkClassIsEnum(Class<?> clz) {
        if ( clz.isEnum() == false )
            throw new NotEnumeratedException(clz + " is not extended from Enum.", clz);
    }

}
